<style lang="less" scoped>
.bg {
  background-size: 100%;
  background-repeat: no-repeat;
}
.btn {
  margin: auto;
  &:extend(.bg);
  width: 268px;
  height: 48px;
  font-size: 19px;
  color: #fff;
  line-height: 44px;
  text-align: center;
}
.borderBottom(@bdColor) {
  position: relative;
  &:after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    background: @bdColor;
    height: 1px;
    width: 100%;
    -webkit-transform: scaleY(0.5);
    transform: scaleY(0.5);
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
  }
}
.pop {
  position: fixed;
  width: 327px;
  height: 282px;
  background-image: url("../static/image/bg_pop.png?__sprite");
  .bg();
  z-index: 10;
  top: 19%;
  margin: auto;
  left: 0;
  right: 0;
  padding: 30px 20px 0 20px;
}
@red: #441f00;
.line {
  font-size: 15px;
  color: @red;
  text-align: center;
  line-height: 26px;
}
.calltimes {
  text-align: center;
  font-size: 24px;
  margin: 20px 0;
  font-weight: 600;
  span {
    font-size: 14px;
    font-weight: normal;
  }
}
.per {
  &:extend(.calltimes);
}
.labels {
  font-size: 12px;
  color: @red;
  text-align: center;
  line-height: 20px;
}
.phoneLabel {
  margin-bottom: 20px;
}
.phonesBox {
  height: 100px;
  margin-bottom: 13px;
}
.phones {
  color: @red;
  font-size: 16px;
  line-height: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14px 0;
  span {
    font-weight: 600;
  }
  input {
    font-size: 16px;
    background: rgba(0, 0, 0, 0);
    width: 100%;
    position: absolute;
    top: 0;
    height: 22px;
  }
}
.phoneLine {
  .borderBottom(@red);
  height: 22px;
  width: 140px;
}
.btnConfirm {
  width: 110px;
  height: 37px;
  .bg();
  background-image: url("../static/image/btn_confirm.png?__sprite");
  margin: auto;
}
.btnChange {
  &:extend(.btnConfirm);
  background-image: url("../static/image/btn_change.png?__sprite");
}
.btnBox {
  width: 243px;
  display: flex;
  justify-content: space-between;
  margin: auto;
}
.has {
  margin-bottom: 24px;
}
.btnClose {
  width: 40px;
  height: 40px;
  background-image: url("../static/image/btn_close.png?__sprite");
  display: block;
  .bg();
  position: fixed;
  top: 30px;
  right: 25px;
}
</style>
<template>
  <div class="pop" v-cloak>
  <div class="pop_now" v-if="cur=='now'">
    <div class="line">
      您本次为{{city.city}}体彩公益事业打Call
    </div>
    <div class="calltimes">
      {{info.amount}} <span>次</span>
    </div>
    <div class="line">累积Call值{{info.userAmount}}，全国当前总Call值{{info.totalAmount}}，</div>
    <div class="line">您的Call值占比为{{info.userAmount}}/{{info.totalAmount}}=</div>
    <div class="per">{{per}}%</div>
    <div class="labels">
      Call值越大，中得iphone X的机会越大；每人每天有一次为任一省市自治区打call的机会。您今天已经打call，请明天再来吧
    </div>
  </div>
  <div class="pop_has" v-if="cur=='has'">
        <div class="line">
        您今日打Call次数已用完
      </div>
      <div class="line has">
      明天再来吧～
      </div>
      <div class="line">累积Call值{{info.userAmount}}，全国当前总Call值{{info.totalAmount}}，</div>
      <div class="line">您的Call值占比为{{info.userAmount}}/{{info.totalAmount}}=</div>
      <div class="per">{{per}}%</div>
      <div class="labels">
        Call值越大，中得iphone X的机会越大；每人每天有一次为任一省市自治区打call的机会。您今天已经打call，请明天再来吧
      </div>
  </div>
  <div class="pop_amount" v-if="cur=='amount'">
    <div class="line">
      您的累积Call值
    </div>
    <div class="calltimes">
      {{info.userAmount}} <span>次</span>
    </div>
    <div class="line">累积Call值{{info.userAmount}}，全国当前总Call值{{info.totalAmount}}，</div>
    <div class="line">您的Call值占比为{{info.userAmount}}/{{info.totalAmount}}=</div>
    <div class="per">{{per}}%</div>
    <div class="labels">
      Call值越大，中得iphone X的机会越大；每人每天有一次为任一省市自治区打call的机会。您今天已经打call，请明天再来吧
    </div>
  </div>
  <div class="pop_phone1" v-if="cur=='phone1'">
    <div class="labels phoneLabel">
      1月4日12点进行抽奖；如中奖，将按此号码联系您进行兑奖；如多次填写，则以您最后一次提交的号码为准；如未填写，则视为放弃抽奖。
    </div>
    <form action="" class="phonesBox">
      <div class="phones">
        <span>输入手机号：</span>
        <div class="phoneLine"><input type="number" id="newPhone" v-model="usrPhone" ></div>
      </div>
      <div class="phones"><span>确认手机号：</span>
        <div class="phoneLine"><input type="number" id="newPhone1" v-model="usrPhone1"></div>
      </div>
      <input type="submit" value="" v-show="false">
    </form>
    <div class="btnConfirm" @click="setPhone()"></div>
  </div>
  <div class="pop_phone2" v-if="cur=='phone2'">
    <div class="labels phoneLabel">
      1月4日12点进行抽奖；如中奖，将按此号码联系您进行兑奖；如多次填写，则以您最后一次提交的号码为准；如未填写，则视为放弃抽奖。
    </div>
    <div class="phonesBox">
      <div class="phones"><span>手机号： {{info.phone}}</span>
        
      </div>
    </div>
    <div class="btnBox">
      <div class="btnChange" @click="changePhone()"></div>
    <div class="btnConfirm"@click="closePop()"></div>
    </div>
  </div>
      <div class="btnClose"@click="closePop()"></div>
</div>
</template>
<script>
import util from "../static/modules/util";
import ajaxData from "../static/modules/ajaxData";
export default {
  props: ["city", "info", "status"],
  data() {
    return {
      usrPhone: "",
      usrPhone1: "",
      cur: this.status || 0
    };
  },
  computed: {
    per() {
      let per = this.info.userAmount / this.info.totalAmount * 100;
      per = util.toFixed(per, 2);
      return per;
    }
  },

  methods: {
    setPhone() {
      let rexPhone = /^1\d{10}$/;
      let self = this;
      function warns(str) {
        let toast = self
          .$createToast({
            time: 1500,
            txt: str,
            type: "warn"
          })
          .show();
      }
      if (!rexPhone.test(this.usrPhone)) {
        warns("手机号格式错误！");
        return;
      } else if (this.usrPhone != this.usrPhone1) {
        warns("两次输入手机号不同！");
        return;
      }
      ajaxData.savePhone2(this.usrPhone, data => {});
    },
    changePhone() {
      this.cur = "phone1";
    },
    closePop() {
      bus.$emit("closePop");
    }
  },
  watch: {
    status(a, b) {
      if (a != b) {
        this.cur = this.status;
      }
    }
  },
  created() {}
};
</script>


